package org.aynu.orderservice.feign;

import org.aynu.productservice.common.ProductResponse;
import org.aynu.productservice.entity.ProductEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

/**
 * 产品服务客户端
 *
 * @author 小粥
 * @since 2025/03/03
 */

@FeignClient(value = "Product-Service")
public interface ProductServiceClient {

    /**
     * 获取产品库存
     *
     * @param map 地图
     * @return {@link ProductResponse }<{@link Integer }>
     * @author 小粥
     * @since 2025/03/03
     */

    @PostMapping("/product/getStock")
    ProductResponse<Integer> getProductStock(@RequestBody Map<String, Object> map);

    /**
     * 更新产品库存
     *
     * @param map 地图
     * @return {@link ProductResponse }<{@link Integer }>
     * @author 小粥
     * @since 2025/03/03
     */

    @PostMapping("/product/updateStock")
    ProductResponse<Integer> updateProductStock(@RequestBody Map<String, Object> map);

    /**
     * 按 ID 获取产品
     *
     * @param map 地图
     * @return {@link ProductResponse }<{@link ProductEntity }>
     * @author 小粥
     * @since 2025/03/03
     */

    @PostMapping("/product/selectProductById")
    ProductResponse<ProductEntity> getProductById(@RequestBody Map<String, Object> map);
}
